import { ElLoading } from 'element-plus';
import i18n from '@/lang/index'

const {t} = i18n.global;
const useLoading = () => {
	// 开启loading画面
	const openLoading = () => {
		const loading = ElLoading.service({
			lock: true,
			text: t('loading'),
			background: 'rgba(0, 0, 0, 0.7)',
		});
		return loading;
	};
	// 关闭loading画面
	const closeLoading = (loading: any) => {
		loading.close();
	};
  return {
	openLoading,
	closeLoading
  }
};

export default useLoading;
